home *** CD-ROM | disk | FTP | other *** search
- // rdata.cpp -- Read data file
-
- //#include <stream.hpp>
- #include <iostream.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- #define MAX 100 // Number of values to write
-
- void error(const char *s);
-
- main()
- {
- double fpArray[MAX];
- int i, n;
- FILE *fp;
-
- fp = fopen("TEST.DAT", "rb");
- if (fp == NULL) error("Can't open TEST.DAT");
- cout << "Reading array from TEST.DAT...\n";
- for (i = 0; i < MAX; i++) {
- if feof(fp) error("Unexpected end of file");
- n = fread(&fpArray[i], sizeof(double), 1, fp);
- if (n != 1) error("Reading data");
- }
- fclose(fp);
- cout << "\nValues read from disk:\n";
- for (i = 0; i < MAX; i++)
- // cout << form("%16.8f", fpArray[i]);
- printf("%16.8f", fpArray[i]);
- }
-
- void error(const char *s)
- {
- cout << "\nERROR: " << s;
- exit(1);
- }
-
-
- // Copyright (c) 1990 by Tom Swan. All rights reserved
- // Revision 1.00 Date: 11/11/1990 Time: 09:11 am
-
- // Revision 1.01 Date: 07/08/1991 Time: 05:41 pm
- // Converted for Borland C++ 2.0
-
-